<template>
    <my-table ref="tableEle" :loading="loading" :lists="tableData" @selectionChange="tableSelect" @pageChange="handleChange" :sequence="true" :page='page' rowKey="cardId" selectKey="all">       
        <el-table-column property="title" label="商品名称" align='left'></el-table-column>
        <el-table-column property="" label="商品售价" align='left'>
            <template slot-scope="scope">
                <span v-if="scope.row.internalPrice">{{scope.row.internalPrice.decimalTwoString}}</span>
            </template>
        </el-table-column>
        <el-table-column property="authorName" label="商品库存" align='center'></el-table-column>
        <el-table-column property="" label="商品历史成交笔数" align='left'>0</el-table-column>
        <el-table-column property="" label="商品历史成交金额$" align='center' width="180px">0
            <!-- <template slot-scope="scope">
                <span v-if="scope.row.internalPrice">{{scope.row.internalPrice.decimalTwoString}}</span>
            </template> -->
        </el-table-column>
    </my-table>
</template>

<script>
import {
  get_app_goods_list
} from '@/api/collext'
import myTable from '@/components/public/myTable';
export default {
    components:{
      myTable
    },
    props:{
        id:''
    },
    data(){
        return{
            page:{
                pageSize:10,
                pageIndex:1,
			    total:0,
            },
            loading:true,
            tableData:[],
            multipleSelectionIds:[],
           // tmselectList:[]
        }
    },
    created(){
        this.getCardList()
    },
    mounted() {
       // this.tmselectList = this.selectList
    },
    methods:{
        getCardList(){ 
            this.loading = true
            get_app_goods_list({
                limit: this.page.pageSize,
                page: this.page.pageIndex,
                orderField: "1",
                orderType: "desc",
                shopId:this.id
            }).then(res=>{
                this.loading = false
                this.tableData = res.data
                this.page.total = res.total
                this.$nextTick(()=>{
                    this.setSelect()
                })
            })
        },
        tableSelect(items){
            this.$emit('change',items)
        },
        handleChange(index) {
            this.page.pageIndex = index;
            this.getCardList();
        },
        setSelect(){
            for(let i=0;i<this.tableData.length;i++){
                const row = this.tableData[i]
                const sdata = this.selectList.find(item => item.cardId == row.cardId)
                sdata && this.$refs.tableEle.setRowSelection(row)
            }
        }
    }
}
</script>
<style lang="scss" scoped>
    .cdimgbox{
        display: flex;
        align-items: center;
        justify-content: center;
        img{
            display: block;
            width: 50px;
        }
    }
</style>